78063aada8285a0616cddd2df54a5b54b9176997,opennms-services/src/main/java/org/opennms/netmgt/capsd/plugins/FtpPlugin.java,FtpPlugin,checkProtocol,#Socket#ConnectionConfig#,132
Before Change
do {
result = lineRdr.readLine();
} while (result != null && result.length() > 0 && MULTILINE_RESULT.match(result));
if (result == null || result.length() == 0) {
log.info("Received truncated response from ftp server " + config.getInetAddress().getHostAddress());
return isAServer;
}
// Tokenize the last line result
//
StringTokenizer t = new StringTokenizer(result);
int rc = Integer.parseInt(t.nextToken());
if (rc > 99 && rc < 600) {
//
// FTP should recoginize the QUIT command
//
String cmd = "QUIT\r\n";
socket.getOutputStream().write(cmd.getBytes());
// Response from QUIT command may be a multi-line response.
// We are expecting to get a response with an integer return
// code in the first token. We can't ge sure that the first
// response will give us what we want. Consider the following
// reponse for example:
//
// 221-You have transferred 0 bytes in 0 files.
// 221-Total traffic for this session was 102 bytes in 0
// transfers.
// 221 Thank you for using the FTP service on nethost0.
//
// In this case the final line of the response contains the
// return
// code we are looking for.
do {
result = lineRdr.readLine();
} while (result != null && result.length() > 0 && MULTILINE_RESULT.match(result));
if (result == null || result.length() == 0) {
log.info("Received truncated response from ftp server " + config.getInetAddress().getHostAddress());
After Change
// This could be anything
// 221 End of header
//
String result = lineRdr.readLine();
if (MULTILINE_RESULT.match(result)) {
// Ok we have a multi-line response...first three
// chars of the response line are the return code.
// The last line of the response will start with
// return code followed by a space.
String multiLineRC = "^" + new String(result.getBytes(), 0, 3) + " ";
/**
* Used to check for the end of a multiline response. The end of a multiline
* response is the same 3 digit response code followed by a space
*/
RE endMultiLineRe;
// Create new regExp to look for last line
// of this mutli line response
try {
endMultiLineRe = new RE(multiLineRC);
} catch (RESyntaxException ex) {
throw new java.lang.reflect.UndeclaredThrowableException(ex);
}
do {
result = lineRdr.readLine();
} while (result != null && !endMultiLineRe.match(result));
}
if (result == null || result.length() == 0) {
log.info("Received truncated response from ftp server " + config.getInetAddress().getHostAddress());
return isAServer;
}
// Tokenize the last line result
//
StringTokenizer t = new StringTokenizer(result);
int rc = Integer.parseInt(t.nextToken());
if (rc > 99 && rc < 600) {
//
// FTP should recoginize the QUIT command
//
String cmd = "QUIT\r\n";
socket.getOutputStream().write(cmd.getBytes());
// Response from QUIT command may be a multi-line response.
// We are expecting to get a response with an integer return
// code in the first token. We can't ge sure that the first
// response will give us what we want. Consider the following
// reponse for example:
//
// 221-You have transferred 0 bytes in 0 files.
// 221-Total traffic for this session was 102 bytes in 0
// transfers.
// 221 Thank you for using the FTP service on nethost0.
//
// In this case the final line of the response contains the
// return
// code we are looking for.
result = lineRdr.readLine();
if (MULTILINE_RESULT.match(result)) {
// Ok we have a multi-line response...first three
// chars of the response line are the return code.
// The last line of the response will start with
// return code followed by a space.
String multiLineRC = "^" + new String(result.getBytes(), 0, 3) + " ";
/**
* Used to check for the end of a multiline response. The end of a multiline
* response is the same 3 digit response code followed by a space
*/
RE endMultiLineRe;
// Create new regExp to look for last line
// of this mutli line response
try {
endMultiLineRe = new RE(multiLineRC);
} catch (RESyntaxException ex) {
throw new java.lang.reflect.UndeclaredThrowableException(ex);
}
do {
result = lineRdr.readLine();
} while (result != null && !endMultiLineRe.match(result));
}
if (result == null || result.length() == 0) {